const ROOT_URL = 'https://tel.aynak.net/';
const API_URL = ROOT_URL + 'api/';
const Http = {
  post: function (url, data, call) {
    uni.request({
      url: API_URL + url,
      data: data,
      method: 'POST',
      success(res) {
        if (call) {
          if (call.success) {
            if (res.data.err == 0) {
              call.success(res.data);
            } else {
              if (call.fail) {
                call.fail(res.data);
              }
            }
          }
        }
      },
      fail: function (err) {
        if (call) {
          if (call.fail) {
            call.fail(err);
          }
        }
      }
    });
  },
  ROOT_URL: ROOT_URL,
  API_URL: API_URL,
};
export default Http